package com.zjw.designPattern.listener.observer;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;

import java.io.IOException;
import java.util.Collection;

/**
 * @description:
 * @author: zhangjiawei
 * @createTime:2022/3/9 16:36
 * @modified by:
 */
@Slf4j
public class FundOfferEventListener implements ObserverListener{

    @Override
    public Logger getLogger() {
        return log;
    }

    @Override
    public void onFundOfferEvent(FundOfferEvent event, long sequence, boolean endOfBatch) throws IOException {
        log.info("start to handle fundOfferEvent: " + sequence);
        Collection<? extends FundOffer> offers = event.getOffers();
        FundOffer oldOffer = event.getOldOffer();
        boolean b = offers.stream().anyMatch(o -> o.getOfferId().equals(oldOffer.getOfferId()));
        log.info("新数据{}老数据",b ? "包含":"不包含");
    }
}
